export const formatNumber = (input) => {
  if (
    input === null ||
    input === undefined ||
    input === ''
  ) {
    return ''
  }

  const isNumeric = (val) => {
    return (
      typeof val === 'number' ||
      (typeof val === 'string' &&
        val.trim() !== '' &&
        !isNaN(Number(val)))
    )
  }

  if (!isNumeric(input)) {
    return String(input) // 非数字字符串，原样返回，转为 string 类型
  }

  const num = Number(input)
  return parseFloat(num.toFixed(2)).toString()
}
